package com.yida.gwj.deposit.service.impl;

import com.yida.common.core.utils.DateUtils;
import com.yida.common.core.utils.StringUtils;
import com.yida.common.security.utils.SecurityUtils;
import com.yida.gwj.deposit.domain.GwjDepositBusinessBuild;
import com.yida.gwj.deposit.mapper.GwjDepositBusinessBuildMapper;
import com.yida.gwj.deposit.service.IGwjDepositBusinessBuildService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 业务楼栋（缴存业务管理模块）Service业务层处理
 *
 * @author lqq
 * @date 2023-01-10
 */
@Service
public class GwjDepositBusinessBuildServiceImpl implements IGwjDepositBusinessBuildService {
	@Resource
	private GwjDepositBusinessBuildMapper gwjDepositBusinessBuildMapper;

	/**
	 * 查询业务楼栋（缴存业务管理模块）
	 *
	 * @param bizBuildId 业务楼栋（缴存业务管理模块）主键
	 * @return 业务楼栋（缴存业务管理模块）
	 */
	@Override
	public GwjDepositBusinessBuild selectGwjDepositBusinessBuildByBizBuildId(Long bizBuildId) {
		return gwjDepositBusinessBuildMapper.selectGwjDepositBusinessBuildByBizBuildId(bizBuildId);
	}

	/**
	 * 查询业务楼栋（缴存业务管理模块）列表
	 *
	 * @param gwjDepositBusinessBuild 业务楼栋（缴存业务管理模块）
	 * @return 业务楼栋（缴存业务管理模块）
	 */
	@Override
	public List<GwjDepositBusinessBuild> selectGwjDepositBusinessBuildList(GwjDepositBusinessBuild gwjDepositBusinessBuild) {
		return gwjDepositBusinessBuildMapper.selectGwjDepositBusinessBuildList(gwjDepositBusinessBuild);
	}

	/**
	 * 新增业务楼栋（缴存业务管理模块）
	 *
	 * @param gwjDepositBusinessBuild 业务楼栋（缴存业务管理模块）
	 * @return 结果
	 */
	@Override
	public int insertGwjDepositBusinessBuild(GwjDepositBusinessBuild gwjDepositBusinessBuild) {
		gwjDepositBusinessBuild.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getRealName());
		gwjDepositBusinessBuild.setCreateTime(DateUtils.getNowDate());
		return gwjDepositBusinessBuildMapper.insertGwjDepositBusinessBuild(gwjDepositBusinessBuild);
	}

	/**
	 * 修改业务楼栋（缴存业务管理模块）
	 *
	 * @param gwjDepositBusinessBuild 业务楼栋（缴存业务管理模块）
	 * @return 结果
	 */
	@Override
	public int updateGwjDepositBusinessBuild(GwjDepositBusinessBuild gwjDepositBusinessBuild) {
		gwjDepositBusinessBuild.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getRealName());
		gwjDepositBusinessBuild.setUpdateTime(DateUtils.getNowDate());
		return gwjDepositBusinessBuildMapper.updateGwjDepositBusinessBuild(gwjDepositBusinessBuild);
	}

	/**
	 * 批量删除业务楼栋（缴存业务管理模块）
	 *
	 * @param bizBuildIds 需要删除的业务楼栋（缴存业务管理模块）主键
	 * @return 结果
	 */
	@Override
	public int deleteGwjDepositBusinessBuildByBizBuildIds(Long[] bizBuildIds) {
		return gwjDepositBusinessBuildMapper.deleteGwjDepositBusinessBuildByBizBuildIds(bizBuildIds);
	}

	/**
	 * 删除业务楼栋（缴存业务管理模块）信息
	 *
	 * @param bizBuildId 业务楼栋（缴存业务管理模块）主键
	 * @return 结果
	 */
	@Override
	public int deleteGwjDepositBusinessBuildByBizBuildId(Long bizBuildId) {
		return gwjDepositBusinessBuildMapper.deleteGwjDepositBusinessBuildByBizBuildId(bizBuildId);
	}

	/**
	 * 通过业务ID查询业务楼栋（缴存业务管理模块）列表
	 *
	 * @param bizId 业务ID
	 * @return 业务楼栋（缴存业务管理模块）集合
	 */
	@Override
	public List<GwjDepositBusinessBuild> selectGwjDepositBusinessBuildListByBizId(Long bizId) {
		GwjDepositBusinessBuild gwjDepositBusinessBuild = new GwjDepositBusinessBuild();
		gwjDepositBusinessBuild.setBizId(bizId);
		return gwjDepositBusinessBuildMapper.selectGwjDepositBusinessBuildList(gwjDepositBusinessBuild);
	}

	/**
	 * 通过业务小区ID查询业务楼栋（缴存业务管理模块）列表
	 *
	 * @param bizCommunityId 业务小区ID
	 * @return 业务楼栋（缴存业务管理模块）集合
	 */
	@Override
	public List<GwjDepositBusinessBuild> selectGwjDepositBusinessBuildListByBizCommunityId(Long bizCommunityId) {
		GwjDepositBusinessBuild gwjDepositBusinessBuild = new GwjDepositBusinessBuild();
		gwjDepositBusinessBuild.setBizCommunityId(bizCommunityId);
		return gwjDepositBusinessBuildMapper.selectGwjDepositBusinessBuildList(gwjDepositBusinessBuild);
	}

	/**
	 * 通过业务ID和楼栋ID查询业务楼栋（缴存业务管理模块）列表
	 *
	 * @param bizId   业务ID
	 * @param buildId 楼栋ID
	 * @return 业务楼栋（缴存业务管理模块）集合
	 */
	@Override
	public GwjDepositBusinessBuild selectGwjDepositBusinessBuildListByBizIdAndBuildId(Long bizId, Long buildId) {
		GwjDepositBusinessBuild gwjDepositBusinessBuild = new GwjDepositBusinessBuild();
		gwjDepositBusinessBuild.setBuildId(buildId);
		gwjDepositBusinessBuild.setBizId(bizId);
		return gwjDepositBusinessBuildMapper.selectGwjDepositBusinessBuild(gwjDepositBusinessBuild);
	}

	/**
	 * 通过业务ID和楼栋标识码查询业务楼栋（缴存业务管理模块）列表
	 *
	 * @param bizId     业务ID
	 * @param buildCode 楼栋标识码
	 * @return 业务楼栋（缴存业务管理模块）集合
	 */
	@Override
	public GwjDepositBusinessBuild selectGwjDepositBusinessBuildListByBizIdAndBuildCode(Long bizId, String buildCode) {
		GwjDepositBusinessBuild gwjDepositBusinessBuild = new GwjDepositBusinessBuild();
		gwjDepositBusinessBuild.setBuildCode(buildCode);
		gwjDepositBusinessBuild.setBizId(bizId);
		return gwjDepositBusinessBuildMapper.selectGwjDepositBusinessBuild(gwjDepositBusinessBuild);
	}

	/**
	 * 根据业务ID删除业务楼栋（缴存业务管理模块）信息
	 *
	 * @param bizId 业务ID
	 * @return 结果
	 */
	@Override
	public int deleteGwjDepositBusinessBuildByBizId(Long bizId) {
		return gwjDepositBusinessBuildMapper.deleteGwjDepositBusinessBuildByBizId(bizId);
	}

	/**
	 * 批量修改业务楼栋（缴存业务管理模块）
	 *
	 * @param gwjDepositBusinessBuilds 业务楼栋（缴存业务管理模块）
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void updateBatchGwjDepositBusinessBuild(List<GwjDepositBusinessBuild> gwjDepositBusinessBuilds) {
		if (StringUtils.isNotEmpty(gwjDepositBusinessBuilds)) {
			gwjDepositBusinessBuilds.forEach(b -> gwjDepositBusinessBuildMapper.updateGwjDepositBusinessBuild(b));
		}
	}

	/**
	 * 批量保存业务楼栋信息
	 * @param builds 业务楼栋信息
	 */
	@Override
	public int insertGwjDepositBusinessBuilds(List<GwjDepositBusinessBuild> builds) {
		return gwjDepositBusinessBuildMapper.insertGwjDepositBusinessBuilds(builds);
	}

	/**
	 * 根据业务楼栋主键查询业务楼栋集合
	 * @param bizBuildIds 业务楼栋主键
	 * @return
	 */
	@Override
	public List<GwjDepositBusinessBuild> selectGwjDepositBusinessBuildListByBizBuildId(Long[] bizBuildIds) {
		return gwjDepositBusinessBuildMapper.selectGwjDepositBusinessBuildListByBizBuildId(bizBuildIds);
	}
}
